<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TBSQL 字符类数据库 - 文档</title>
    <!-- 浏览器图标 -->
    <link rel="icon" type="image/x-icon" href="https://free.picui.cn/free/2025/11/02/6906713c11b45.png">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary: #3498db;
            --primary-dark: #2980b9;
            --secondary: #2c3e50;
            --light: #f8f9fa;
            --dark: #343a40;
            --success: #28a745;
            --warning: #ffc107;
            --danger: #dc3545;
            --gray: #6c757d;
            --border-radius: 10px;
            --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s ease;
            --sidebar-width: 300px;
        }
        
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            color: var(--dark);
            line-height: 1.6;
            min-height: 100vh;
            padding: 0;
            overflow-x: hidden;
        }
        
        /* 顶部导航栏 */
        .top-nav {
            background: white;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
            padding: 15px 0;
        }
        
        .nav-container {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 20px;
        }
        
        .logo {
            display: flex;
            align-items: center;
            font-weight: bold;
            color: var(--secondary);
            font-size: 1.5rem;
            text-decoration: none;
        }
        
        .logo-image {
            width: 40px;
            height: 40px;
            margin-right: 10px;
            background: var(--primary);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 1.2rem;
        }
        
        .nav-controls {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .control-btn {
            background: transparent;
            border: 1px solid var(--primary);
            color: var(--primary);
            padding: 8px 15px;
            border-radius: 5px;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        .control-btn:hover {
            background: var(--primary);
            color: white;
        }
        
        .control-btn.active {
            background: var(--primary);
            color: white;
        }
        
        .mobile-menu-btn {
            display: none;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: 5px;
            padding: 10px;
            font-size: 1.2rem;
            cursor: pointer;
        }
        
        /* 侧边栏导航 */
        .sidebar {
            width: var(--sidebar-width);
            background: white;
            position: fixed;
            left: 0;
            top: 70px;
            height: calc(100vh - 70px);
            overflow-y: auto;
            box-shadow: var(--shadow);
            z-index: 999;
            transition: var(--transition);
            transform: translateX(-100%);
        }
        
        .sidebar.active {
            transform: translateX(0);
        }
        
        .sidebar-header {
            padding: 20px;
            background: var(--primary);
            color: white;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        .sidebar-logo {
            width: 60px;
            height: 60px;
            background: white;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 10px;
            color: var(--primary);
            font-weight: bold;
            font-size: 1.5rem;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        
        .sidebar-nav {
            padding: 15px 0;
        }
        
        .nav-section {
            margin-bottom: 20px;
        }
        
        .nav-section-title {
            padding: 10px 20px;
            font-weight: 600;
            color: var(--secondary);
            border-bottom: 1px solid #eee;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            cursor: pointer;
        }
        
        .nav-section-title i {
            margin-right: 10px;
            color: var(--primary);
            transition: var(--transition);
        }
        
        .nav-section-title.active i {
            transform: rotate(90deg);
        }
        
        .nav-items {
            max-height: 0;
            overflow: hidden;
            transition: var(--transition);
        }
        
        .nav-section.active .nav-items {
            max-height: 1000px;
        }
        
        .nav-item {
            display: block;
            padding: 10px 20px 10px 30px;
            color: var(--dark);
            text-decoration: none;
            transition: var(--transition);
            border-left: 3px solid transparent;
        }
        
        .nav-item:hover, .nav-item.active {
            background: rgba(52, 152, 219, 0.1);
            border-left-color: var(--primary);
            color: var(--primary);
        }
        
        .nav-item i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
        }
        
        /* 主内容区域 */
        .main-content {
            margin-left: 0;
            padding: 90px 30px 30px;
            transition: var(--transition);
        }
        
        .main-content.with-sidebar {
            margin-left: var(--sidebar-width);
        }
        
        .section {
            background: white;
            border-radius: var(--border-radius);
            padding: 25px;
            margin-bottom: 25px;
            box-shadow: var(--shadow);
            display: none;
        }
        
        .section.active {
            display: block;
            animation: fadeIn 0.5s ease;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .section-title {
            color: var(--secondary);
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--primary);
            font-size: 1.5rem;
            display: flex;
            align-items: center;
        }
        
        .section-title i {
            margin-right: 10px;
            color: var(--primary);
        }
        
        .card-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }
        
        .card {
            background: var(--light);
            border-radius: var(--border-radius);
            padding: 20px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.05);
            transition: var(--transition);
            border-left: 4px solid var(--primary);
            height: 100%;
            display: flex;
            flex-direction: column;
        }
        
        .card:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        
        .card h3 {
            color: var(--secondary);
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid #ddd;
            font-size: 1.2rem;
            display: flex;
            align-items: center;
        }
        
        .card h3 i {
            margin-right: 8px;
            color: var(--primary);
        }
        
        .card-content {
            flex-grow: 1;
        }
        
        .card-content ul {
            padding-left: 20px;
            margin-bottom: 15px;
        }
        
        .card-content li {
            margin-bottom: 8px;
        }
        
        .code-block {
            background: #2d3748;
            color: #e2e8f0;
            border-radius: 6px;
            padding: 15px;
            margin: 10px 0;
            font-family: 'Consolas', monospace;
            font-size: 0.9rem;
            overflow-x: auto;
            line-height: 1.4;
        }
        
        .highlight {
            background-color: rgba(255, 243, 205, 0.5);
            padding: 2px 5px;
            border-radius: 3px;
            font-weight: 500;
        }
        
        .note {
            background-color: #e8f4fd;
            border-left: 4px solid var(--primary);
            padding: 12px 15px;
            margin: 15px 0;
            border-radius: 0 4px 4px 0;
        }
        
        .warning {
            background-color: #f8d7da;
            border-left: 4px solid var(--danger);
            padding: 12px 15px;
            margin: 15px 0;
            border-radius: 0 4px 4px 0;
        }
        
        .data-model {
            display: flex;
            justify-content: space-around;
            flex-wrap: wrap;
            margin: 20px 0;
        }
        
        .model-item {
            background: white;
            padding: 15px;
            border-radius: 8px;
            box-shadow: 0 3px 10px rgba(0,0,0,0.08);
            margin: 10px;
            min-width: 250px;
            flex: 1;
        }
        
        .model-title {
            font-weight: bold;
            margin-bottom: 10px;
            color: var(--secondary);
            display: flex;
            align-items: center;
        }
        
        .model-title i {
            margin-right: 8px;
            color: var(--primary);
        }
        
        .command-table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
            font-size: 0.9rem;
        }
        
        .command-table th, .command-table td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: left;
        }
        
        .command-table th {
            background-color: var(--primary);
            color: white;
        }
        
        .command-table tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        
        .footer {
            text-align: center;
            margin-top: 40px;
            padding: 20px;
            color: var(--gray);
            font-size: 0.9rem;
            border-top: 1px solid #eee;
        }
        
        /* 首页样式 */
        .home-section {
            text-align: center;
            padding: 60px 20px;
        }
        
        .home-logo {
            width: 120px;
            height: 120px;
            background: var(--primary);
            border-radius: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 30px;
            color: white;
            font-weight: bold;
            font-size: 2.5rem;
            box-shadow: 0 8px 20px rgba(52, 152, 219, 0.3);
        }
        
        .home-section h1 {
            font-size: 3rem;
            margin-bottom: 20px;
            color: var(--secondary);
        }
        
        .home-section p {
            font-size: 1.2rem;
            max-width: 800px;
            margin: 0 auto 30px;
            color: var(--gray);
        }
        
        .feature-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-top: 40px;
        }
        
        .feature-card {
            background: white;
            border-radius: var(--border-radius);
            padding: 25px;
            box-shadow: var(--shadow);
            transition: var(--transition);
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        
        .feature-card i {
            font-size: 2.5rem;
            color: var(--primary);
            margin-bottom: 15px;
        }
        
        .feature-card h3 {
            margin-bottom: 15px;
            color: var(--secondary);
        }
        
        /* 语言选项样式 */
        .language-selector {
            position: relative;
        }
        
        .language-dropdown {
            position: absolute;
            top: 100%;
            right: 0;
            background: white;
            border-radius: 5px;
            box-shadow: var(--shadow);
            padding: 10px 0;
            min-width: 150px;
            display: none;
            z-index: 1001;
        }
        
        .language-dropdown.active {
            display: block;
        }
        
        .language-option {
            padding: 8px 15px;
            cursor: pointer;
            transition: var(--transition);
        }
        
        .language-option:hover {
            background: rgba(52, 152, 219, 0.1);
            color: var(--primary);
        }
        
        /* 移动端样式 */
        @media (max-width: 992px) {
            .main-content.with-sidebar {
                margin-left: 0;
            }
            
            .mobile-menu-btn {
                display: block;
            }
            
            .card-container {
                grid-template-columns: 1fr;
            }
            
            .section-title {
                font-size: 1.3rem;
            }
            
            .home-section h1 {
                font-size: 2.2rem;
            }
            
            .home-section p {
                font-size: 1rem;
            }
            
            .nav-controls .control-text {
                display: none;
            }
            
            .control-btn {
                padding: 8px 10px;
            }
            
            .home-logo {
                width: 100px;
                height: 100px;
                font-size: 2rem;
            }
        }
        
        /* 桌面端大屏幕优化 */
        @media (min-width: 1200px) {
            .card-container {
                grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
            }
            
            .sidebar {
                transform: translateX(0);
            }
            
            .main-content {
                margin-left: var(--sidebar-width);
            }
            
            .mobile-menu-btn {
                display: none;
            }
        }
        
        /* 移动端小屏幕优化 */
        @media (max-width: 576px) {
            .main-content {
                padding: 90px 15px 15px;
            }
            
            .section {
                padding: 15px;
            }
            
            .data-model {
                flex-direction: column;
            }
            
            .model-item {
                min-width: 100%;
                margin: 10px 0;
            }
            
            .command-table {
                font-size: 0.8rem;
            }
            
            .command-table th, .command-table td {
                padding: 8px;
            }
            
            .home-section {
                padding: 40px 15px;
            }
            
            .home-section h1 {
                font-size: 1.8rem;
            }
            
            .home-logo {
                width: 80px;
                height: 80px;
                font-size: 1.8rem;
            }
        }
        
        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 8px;
        }
        
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }
        
        ::-webkit-scrollbar-thumb {
            background: var(--primary);
            border-radius: 4px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: var(--primary-dark);
        }
        
        /* 返回顶部按钮 */
        .back-to-top {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: var(--primary);
            color: white;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            box-shadow: var(--shadow);
            cursor: pointer;
            z-index: 99;
            transition: var(--transition);
            opacity: 0;
            visibility: hidden;
        }
        
        .back-to-top.active {
            opacity: 1;
            visibility: visible;
        }
        
        .back-to-top:hover {
            background: var(--primary-dark);
            transform: translateY(-3px);
        }
        
        /* 目录结构可视化 */
        .directory-tree {
            background: #f8f9fa;
            border-radius: 8px;
            padding: 15px;
            margin: 15px 0;
            font-family: 'Consolas', monospace;
            line-height: 1.8;
        }
        
        /* 锁机制可视化 */
        .lock-visual {
            display: flex;
            justify-content: space-around;
            margin: 20px 0;
            flex-wrap: wrap;
        }
        
        .lock-item {
            background: white;
            border-radius: 8px;
            padding: 15px;
            box-shadow: 0 3px 10px rgba(0,0,0,0.08);
            margin: 10px;
            text-align: center;
            flex: 1;
            min-width: 200px;
        }
        
        .lock-item i {
            font-size: 2rem;
            color: var(--primary);
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    <!-- 顶部导航栏 -->
    <div class="top-nav">
        <div class="nav-container">
            <a href="#home" class="logo" data-section="home">
                <div class="logo-image">TBS</div>
                <span>TBSQL</span>
            </a>
            <div class="nav-controls">
                    </button>
                </div>
                <button class="control-btn" id="viewToggle">
                    <i class="fas fa-desktop"></i>
                    <span class="control-text">桌面视图</span>
                </button>
                <button class="mobile-menu-btn" id="mobileMenuBtn">
                    <i class="fas fa-bars"></i>
                </button>
            </div>
        </div>
    </div>
    
    <!-- 侧边栏导航 -->
    <div class="sidebar" id="sidebar">
        <div class="sidebar-header">
            <div class="sidebar-logo">TBS</div>
            <h2>TBSQL 文档</h2>
            <p>字符类数据库</p>
        </div>
        
        <div class="sidebar-nav">
            <div class="nav-section active">
                <div class="nav-section-title">
                    <i class="fas fa-chevron-right"></i>
                    <span>核心概念</span>
                </div>
                <div class="nav-items">
                    <a href="#home" class="nav-item active" data-section="home"><i class="fas fa-home"></i> 首页</a>
                    <a href="#intro" class="nav-item" data-section="intro"><i class="fas fa-info-circle"></i> 简介</a>
                    <a href="#design" class="nav-item" data-section="design"><i class="fas fa-pencil-ruler"></i> 设计理念</a>
                    <a href="#data-model" class="nav-item" data-section="data-model"><i class="fas fa-database"></i> 数据模型</a>
                </div>
            </div>
            
            <div class="nav-section">
                <div class="nav-section-title">
                    <i class="fas fa-chevron-right"></i>
                    <span>数据类型系统</span>
                </div>
                <div class="nav-items">
                    <a href="#types" class="nav-item" data-section="types"><i class="fas fa-list"></i> 类型定义</a>
                    <a href="#rules" class="nav-item" data-section="rules"><i class="fas fa-ruler"></i> 使用规则</a>
                </div>
            </div>
            
            <div class="nav-section">
                <div class="nav-section-title">
                    <i class="fas fa-chevron-right"></i>
                    <span>系统架构</span>
                </div>
                <div class="nav-items">
                    <a href="#indexing" class="nav-item" data-section="indexing"><i class="fas fa-search"></i> 索引方案</a>
                    <a href="#file-structure" class="nav-item" data-section="file-structure"><i class="fas fa-folder"></i> 文件组织</a>
                    <a href="#config" class="nav-item" data-section="config"><i class="fas fa-cog"></i> 配置系统</a>
                </div>
            </div>
            
            <div class="nav-section">
                <div class="nav-section-title">
                    <i class="fas fa-chevron-right"></i>
                    <span>操作命令</span>
                </div>
                <div class="nav-items">
                    <a href="#commands" class="nav-item" data-section="commands"><i class="fas fa-code"></i> 终端命令</a>
                    <a href="#concurrency" class="nav-item" data-section="concurrency"><i class="fas fa-lock"></i> 并发控制</a>
                </div>
            </div>
            
            <div class="nav-section">
                <div class="nav-section-title">
                    <i class="fas fa-chevron-right"></i>
                    <span>高级功能</span>
                </div>
                <div class="nav-items">
                    <a href="#service-registry" class="nav-item" data-section="service-registry"><i class="fas fa-clipboard-list"></i> 服务注册表</a>
                    <a href="#schema" class="nav-item" data-section="schema"><i class="fas fa-project-diagram"></i> 模式定义</a>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 主内容区域 -->
    <div class="main-content" id="mainContent">
        <!-- 首页 -->
        <section class="section active" id="home">
            <div class="home-section">
                <div class="home-logo">TBS</div>
                <h1>TBSQL 字符类数据库</h1>
                <p>文本比特类数据库 (TextBiteSQL) - 轻量级配置型数据存储解决方案</p>
                
                <div class="feature-cards">
                    <div class="feature-card">
                        <i class="fas fa-database"></i>
                        <h3>轻量级设计</h3>
                        <p>专为简单映射、常数定义和商品信息等场景设计</p>
                    </div>
                    <div class="feature-card">
                        <i class="fas fa-file-code"></i>
                        <h3>文件存储</h3>
                        <p>使用.tbs文件格式，直观易懂的数据模型</p>
                    </div>
                    <div class="feature-card">
                        <i class="fas fa-bolt"></i>
                        <h3>高性能</h3>
                        <p>单表支持百万级数据存储，快速索引方案</p>
                    </div>
                    <div class="feature-card">
                        <i class="fas fa-lock"></i>
                        <h3>并发安全</h3>
                        <p>完整的并发控制机制，确保数据一致性</p>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 简介部分 -->
        <section class="section" id="intro">
            <h2 class="section-title"><i class="fas fa-info-circle"></i> 简介</h2>
            <div class="card-container">
                <div class="card">
                    <h3><i class="fas fa-language"></i> 名称定义</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">中文名称</span>：字符类数据库</li>
                            <li><span class="highlight">全称</span>：文本比特类数据库 (TextBiteSQL)</li>
                            <li><span class="highlight">简称</span>：TBSQL (T-Text 文本 | B-Bite 比特 | SQL-数据库)</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-bullseye"></i> 用途</h3>
                    <div class="card-content">
                        <p>TBSQL是一种配置性类数据库，适用于：</p>
                        <ul>
                            <li>简单映射</li>
                            <li>常数定义</li>
                            <li>商品信息</li>
                            <li>配置型数据存储</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-file-code"></i> 文件结构</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">文件扩展名</span>：.tbs</li>
                            <li><span class="highlight">组成</span>：行标识（ids）和列定义（token）</li>
                            <li><span class="highlight">单表容量</span>：0 - 1,000,000 行（仅支持正整数）</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 设计理念部分 -->
        <section class="section" id="design">
            <h2 class="section-title"><i class="fas fa-pencil-ruler"></i> 设计理念</h2>
            <div class="card">
                <div class="card-content">
                    <ul>
                        <li>采用类数轴概念，区域参考阴影，ids轴需要翻转</li>
                        <li>单表可表达数位于 0-10⁶个内（正整数）</li>
                        <li>勿使用负数或小数防止处理异常</li>
                    </ul>
                    <div class="code-block">
数轴示意图：
值(token)
↑
│   ┌───┬───┬───┐
│   │   │   │   │ 
│   ├───┼───┼───┤
│   │ 值 │ 值 │ 值 │
│   ├───┼───┼───┤
│   │ 值 │ 值 │ 值 │
│   └───┴───┴───┘
│
└──────────────────→ 键(ids)
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 数据模型部分 -->
        <section class="section" id="data-model">
            <h2 class="section-title"><i class="fas fa-database"></i> 数据模型</h2>
            <div class="data-model">
                <div class="model-item">
                    <div class="model-title"><i class="fas fa-book"></i> 术语定义</div>
                    <ul>
                        <li><span class="highlight">ID</span>: 唯一标识符</li>
                        <li><span class="highlight">token</span>: 值定义（列名）</li>
                        <li><span class="highlight">ids</span>: 键（行标识）</li>
                        <li><span class="highlight">值</span>: 具体数据</li>
                    </ul>
                </div>
                <div class="model-item">
                    <div class="model-title"><i class="fas fa-table"></i> 实际存储结构</div>
                    <div class="code-block">
ID   token₁  token₂  token₃
ids₁→┌───┬──────┬──────┬──────┐
│   │  值  │  值  │  值  │
ids₂→├───┼──────┼──────┼──────┤
│   │  值  │  值  │  值  │
└───┴──────┴──────┴──────┘
                    </div>
                </div>
            </div>
            <div class="note">
                注意：第一行都是值定义，单表容量：0 - 1,000,000 行（仅支持正整数）
            </div>
        </section>
        
        <!-- 数据类型系统部分 -->
        <section class="section" id="types">
            <h2 class="section-title"><i class="fas fa-list"></i> 类型定义</h2>
            <div class="card-container">
                <div class="card">
                    <h3><i class="fas fa-cube"></i> 数据类型</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">int</span>：整数</li>
                            <li><span class="highlight">float</span>：小数</li>
                            <li><span class="highlight">bool</span>：布尔</li>
                            <li><span class="highlight">STR</span>：字符串类型（默认）</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-code"></i> 使用规则</h3>
                    <div class="card-content">
                        <ul>
                            <li>值定义可用 <span class="highlight">=/=</span> 表达字符串类型</li>
                            <li>字符串类型是STR，可以不写，遇到解析问题时可以写上去</li>
                            <li>示例整数定义方式：<span class="highlight">123=/=int</span></li>
                            <li>前表都是默认STR类型来解析</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 索引方案部分 -->
        <section class="section" id="indexing">
            <h2 class="section-title"><i class="fas fa-search"></i> 索引方案</h2>
            <div class="card">
                <div class="card-content">
                    <ul>
                        <li><span class="highlight">方式</span>：逐行扫描，首字段匹配</li>
                        <li><span class="highlight">流程</span>：
                            <ol>
                                <li>定位表头，确认ID列位置（首列）</li>
                                <li>读取数据行，检测第一个分号 ;</li>
                                <li>提取分号前字符串作为当前行ID</li>
                                <li>比较当前行ID与目标ID：
                                    <ul>
                                        <li>匹配：完整读取该行，返回数据</li>
                                        <li>不匹配：立即终止当前行读取，跳转至下一行</li>
                                    </ul>
                                </li>
                                <li>重复直至找到目标或文件结束</li>
                            </ol>
                        </li>
                    </ul>
                    <div class="note">
                        优化：避免全行分割，仅解析首字段
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 文件组织部分 -->
        <section class="section" id="file-structure">
            <h2 class="section-title"><i class="fas fa-folder"></i> 文件组织架构</h2>
            <div class="card-container">
                <div class="card">
                    <h3><i class="fas fa-sitemap"></i> 层级结构</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">TBE</span>：单个 .tbs 文件（表）</li>
                            <li><span class="highlight">TBZ</span>：40个TBE为一组</li>
                            <li><span class="highlight">TBP</span>：40个TBZ为一堆</li>
                            <li><span class="highlight">TO</span>：全部TBP为一"奇"（奇点之意）</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-file-alt"></i> IDE文件系统</h3>
                    <div class="card-content">
                        <ul>
                            <li>使用 <span class="highlight">.ide</span> 文件存储文件树内所有ID值以力键来搜索</li>
                            <li>每个文件内不存在相同ID，所在的TO内也不存在相同ID</li>
                        </ul>
                        <div class="code-block">
IDE文件演示内容：
ID:1-99 PATH:TO
UNAME:演示数据库
ID:1-999 PATH:TO
UNAME:演示名
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-folder-tree"></i> 目录结构</h3>
                    <div class="card-content">
                        <div class="directory-tree">
TO<br>
├─Sign/<br>
│└sign.txt<br>
├─Service Registry/<br>
│└Service Registry.tbs<br>
├─TO.ide<br>
├─TBP/<br>
│└─TBP.ide<br>
│└─TBZ/<br>
│├─TBZ.ide<br>
│└─TBE/<br>
│├─TBE.ide<br>
│└─TBE.tbs
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 配置系统部分 -->
        <section class="section" id="config">
            <h2 class="section-title"><i class="fas fa-cog"></i> 配置系统</h2>
            <div class="card">
                <div class="card-content">
                    <p><span class="highlight">sign</span>: 配置信息，让您更开心的使用一个您更喜欢的类数据库</p>
                    <div class="note">
                        实际使用时Sign在Sign文件夹内
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 终端命令部分 -->
        <section class="section" id="commands">
            <h2 class="section-title"><i class="fas fa-terminal"></i> 终端操作命令</h2>
            <div class="card-container">
                <div class="card">
                    <h3><i class="fas fa-comments"></i> 交互命令</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">SPA SAY INIT</span>- 唤起菜单交互</li>
                        </ul>
                        <div class="code-block">
SPA以交互来完成设置
TBS SPA（启动菜单）
TBS SPA 项目 值（快捷控制项目状态）

INIT不支持快捷操作，故相关命令仅TBS INIT

SAY与SPA类似
TBS SAY（启动菜单）
TBS SAY 语言（快捷切换语言）
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-tools"></i> 操作命令</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">find ls move lssign add rmrf echo</span>- 直接操作库内容</li>
                        </ul>
                        <table class="command-table">
                            <tr>
                                <th>命令</th>
                                <th>语法</th>
                                <th>说明</th>
                            </tr>
                            <tr>
                                <td>find</td>
                                <td>TBS find 表名 ID</td>
                                <td>查找后给出路径并列出ID值与所有键值</td>
                            </tr>
                            <tr>
                                <td>add</td>
                                <td>TBS add 表名 数值</td>
                                <td>创建ID值，控制数量</td>
                            </tr>
                            <tr>
                                <td>ls</td>
                                <td>TBS ls 地址</td>
                                <td>列出指定ID区内所有ID值与值</td>
                            </tr>
                            <tr>
                                <td>rmrf</td>
                                <td>TBS rmrf 表名 ID/值 键/ID与值</td>
                                <td>删除后自动重对齐</td>
                            </tr>
                            <tr>
                                <td>move</td>
                                <td>TBS move 表名 A键 B键 交换值</td>
                                <td>B键不填时移动至最后，交换值不填时全部交换</td>
                            </tr>
                            <tr>
                                <td>echo</td>
                                <td>TBS echo-n 表名 值名（添加值）<br>TBS echo 表名 ID 值名 内容（修改值）</td>
                                <td>修改或添加值</td>
                            </tr>
                            <tr>
                                <td>ls sign</td>
                                <td>TBS lssign（列出所有设置）<br>TBS lssign 分类/项目名（列出指定项目设置）</td>
                                <td>列出设置</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 并发控制部分 -->
        <section class="section" id="concurrency">
            <h2 class="section-title"><i class="fas fa-lock"></i> 并发控制方案</h2>
            <div class="card-container">
                <div class="card">
                    <h3><i class="fas fa-atom"></i> 原子操作保障</h3>
                    <div class="card-content">
                        <ul>
                            <li>写操作（add,rmrf,echo,move）采用原子化设计</li>
                            <li>文件锁机制确保多进程操作数据一致性</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-file-lock"></i> 锁文件设计</h3>
                    <div class="card-content">
                        <ul>
                            <li>每个.tbs表文件对应锁文件：<span class="highlight">{表名}.tbs.lock</span></li>
                            <li>锁文件内容：进程ID:时间戳</li>
                        </ul>
                        <div class="code-block">
示例：12345:2024-01-15T10:30:00
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-key"></i> 加锁规则</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">写操作加锁</span>：add,rmrf, move, echo (修改值)</li>
                            <li><span class="highlight">读操作共享</span>：find,ls, lssign</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-clock"></i> 锁超时机制</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">最大锁等待</span>：30秒</li>
                            <li><span class="highlight">锁超时时间</span>：5分钟</li>
                            <li><span class="highlight">检查间隔</span>：100毫秒</li>
                        </ul>
                    </div>
                </div>
            </div>
            
            <div class="lock-visual">
                <div class="lock-item">
                    <i class="fas fa-lock"></i>
                    <h4>写操作加锁</h4>
                    <p>add, rmrf, move, echo</p>
                </div>
                <div class="lock-item">
                    <i class="fas fa-lock-open"></i>
                    <h4>读操作共享</h4>
                    <p>find, ls, lssign</p>
                </div>
                <div class="lock-item">
                    <i class="fas fa-hourglass-half"></i>
                    <h4>锁超时</h4>
                    <p>5分钟</p>
                </div>
            </div>
        </section>
        
        <!-- 服务注册表部分 -->
        <section class="section" id="service-registry">
            <h2 class="section-title"><i class="fas fa-tasks"></i> Service Registry 服务注册表</h2>
            <div class="card-container">
                <div class="card">
                    <h3><i class="fas fa-lightbulb"></i> 设计理念</h3>
                    <div class="card-content">
                        <p>自动管理的待办任务队列，任务完成后自动删除</p>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-table"></i> 表结构</h3>
                    <div class="card-content">
                        <div class="code-block">
ID;service_name;status;created_at;target_date;task_type
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-list-alt"></i> 字段说明</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">ID</span>:任务唯一标识</li>
                            <li><span class="highlight">service_name</span>:任务名称</li>
                            <li><span class="highlight">status</span>:状态（active|completed）</li>
                            <li><span class="highlight">created_at</span>:创建时间</li>
                            <li><span class="highlight">target_date</span>:计划完成日期</li>
                            <li><span class="highlight">task_type</span>:任务类型（file_operation|system_operation）</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-robot"></i> 自动管理规则</h3>
                    <div class="card-content">
                        <ul>
                            <li>系统初始化时自动插入待办任务</li>
                            <li>任务完成时自动标记为completed</li>
                            <li>文件操作任务最长执行时间1小时</li>
                            <li>completed状态任务1小时后自动删除</li>
                            <li>不提供 add/update/remove 命令</li>
                        </ul>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-tasks"></i> 默认待办任务</h3>
                    <div class="card-content">
                        <div class="code-block">
1;concurrency_control;completed;2024-01-15;2024-02-01;file_operation
2;server_architecture;active;2024-01-15;2024-02-15;file_operation
3;storage_efficiency;active;2024-01-15;2024-03-01;system_operation
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-search"></i> 只读查询命令</h3>
                    <div class="card-content">
                        <ul>
                            <li><span class="highlight">TBS service status</span>（查看当前待办任务状态）</li>
                            <li><span class="highlight">TBS service completed</span>（查看已完成任务历史）</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 模式定义部分 -->
        <section class="section" id="schema">
            <h2 class="section-title"><i class="fas fa-project-diagram"></i> 模式定义</h2>
            <div class="card-container">
                <div class="card">
                    <h3><i class="fas fa-lightbulb"></i> 设计理念</h3>
                    <div class="card-content">
                        <p>查询时通过第一行的值定义获取类型，输出时值附带类型信息</p>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-code"></i> 模式格式</h3>
                    <div class="card-content">
                        <div class="code-block">
ID:INT;name:STR;age:INT;email:STR
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-file-export"></i> 输出规则</h3>
                    <div class="card-content">
                        <p>查询时返回带类型标记的值：</p>
                        <div class="code-block">
ID=1=/=INT;name=张三=/=STR;age=25=/=INT;email=zhangsan@email.com=/=STR
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-file-code"></i> 使用示例</h3>
                    <div class="card-content">
                        <p>user_info.tbs:</p>
                        <div class="code-block">
ID:INT;name:STR;age:INT;email:STR
1;张三;25;zhangsan@email.com
2;李四;30;lisi@email.com
                        </div>
                        <p>查询输出：</p>
                        <div class="code-block">
TBS find user_info 1
输出：ID=1=/=INT;name=张三=/=STR;age=25=/=INT;email=zhangsan@email.com=/=STR
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <h3><i class="fas fa-cogs"></i> 解析过程</h3>
                    <div class="card-content">
                        <ul>
                            <li>读取第一行获取每个列的类型</li>
                            <li>查询数据时，为每个值附加类型标记</li>
                            <li>输出格式：列名=值=/=类型</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- 页脚 -->
        <div class="footer">
            <p>TBSQL 字符类数据库完整文档 | 基于概念.txt整理 | 2024年</p>
        </div>
    </div>
    
    <!-- 返回顶部按钮 -->
    <div class="back-to-top" id="backToTop">
        <i class="fas fa-arrow-up"></i>
    </div>
    
    <script>
        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            // 设置桌面视图
            if (window.innerWidth > 992) {
                document.getElementById('sidebar').classList.add('active');
                document.getElementById('mainContent').classList.add('with-sidebar');
            }
            
            // 激活首页
            activateSection('home');
        });
        
        // 移动端菜单切换
        document.getElementById('mobileMenuBtn').addEventListener('click', function() {
            document.getElementById('sidebar').classList.toggle('active');
        });
        
        // 导航项点击事件
        document.querySelectorAll('.nav-item').forEach(item => {
            item.addEventListener('click', function(e) {
                e.preventDefault();
                
                // 移除所有激活状态
                document.querySelectorAll('.nav-item').forEach(nav => {
                    nav.classList.remove('active');
                });
                
                // 添加当前激活状态
                this.classList.add('active');
                
                // 获取目标章节
                const targetSection = this.getAttribute('data-section');
                
                // 激活对应章节
                activateSection(targetSection);
                
                // 在移动端关闭菜单
                if (window.innerWidth <= 992) {
                    document.getElementById('sidebar').classList.remove('active');
                }
            });
        });
        
        // 章节激活函数
        function activateSection(sectionId) {
            // 隐藏所有章节
            document.querySelectorAll('.section').forEach(section => {
                section.classList.remove('active');
            });
            
            // 显示目标章节
            document.getElementById(sectionId).classList.add('active');
            
            // 滚动到顶部
            window.scrollTo(0, 0);
        }
        
        // 导航章节标题点击事件
        document.querySelectorAll('.nav-section-title').forEach(title => {
            title.addEventListener('click', function() {
                this.parentElement.classList.toggle('active');
            });
        });
        
        // 视图切换
        document.getElementById('viewToggle').addEventListener('click', function() {
            const isDesktop = document.getElementById('mainContent').classList.contains('with-sidebar');
            
            if (isDesktop) {
                // 切换到移动视图
                document.getElementById('mainContent').classList.remove('with-sidebar');
                document.getElementById('sidebar').classList.remove('active');
                this.innerHTML = '<i class="fas fa-mobile-alt"></i><span class="control-text">移动视图</span>';
            } else {
                // 切换到桌面视图
                document.getElementById('mainContent').classList.add('with-sidebar');
                document.getElementById('sidebar').classList.add('active');
                this.innerHTML = '<i class="fas fa-desktop"></i><span class="control-text">桌面视图</span>';
            }
        });
        
        // 返回顶部按钮
        window.addEventListener('scroll', function() {
            const backToTop = document.getElementById('backToTop');
            if (window.pageYOffset > 300) {
                backToTop.classList.add('active');
            } else {
                backToTop.classList.remove('active');
            }
        });
        
        document.getElementById('backToTop').addEventListener('click', function() {
            window.scrollTo({
                top: 0,
                behavior: 'smooth'
            });
        });
        
        // 点击页面其他区域关闭语言下拉菜单
        document.addEventListener('click', function(e) {
            if (!e.target.closest('.language-selector')) {
                document.getElementById('languageDropdown').classList.remove('active');
            }
        });
        
        // 响应式处理
        window.addEventListener('resize', function() {
            if (window.innerWidth > 992) {
                // 桌面端
                document.getElementById('sidebar').classList.add('active');
                document.getElementById('mainContent').classList.add('with-sidebar');
                document.getElementById('viewToggle').innerHTML = '<i class="fas fa-desktop"></i><span class="control-text">桌面视图</span>';
            } else {
                // 移动端
                document.getElementById('sidebar').classList.remove('active');
                document.getElementById('mainContent').classList.remove('with-sidebar');
                document.getElementById('viewToggle').innerHTML = '<i class="fas fa-mobile-alt"></i><span class="control-text">移动视图</span>';
            }
        });
    </script>
</body>
</html>